from pages.base_page import BasePage
from selenium.webdriver.common.by import By


class EditProductPage(BasePage):
    url = '/crm/index.php?m=product'

    suggested_price_locator = (By.ID, 'suggested_price')
    save_button_locator = (By.CSS_SELECTOR, '#form1 > table > tfoot > tr > td > input.btn.btn-primary')
    save_success_locator = (By.CSS_SELECTOR, 'body > div.container > div.alert.alert-success')

    # 清空建议价格
    def clear_suggested_price(self):
        self.driver.find_element(*self.suggested_price_locator).clear()
    # 输入建议价格
    def input_suggested_price(self, suggested_price):
        self.driver.find_element(*self.suggested_price_locator).send_keys(suggested_price)

    #点击保存按钮
    def click_save_button(self):
        self.driver.find_element(*self.save_button_locator).click()
    #返回保存成功的提示信息
    def save_success_info(self):
        return self.driver.find_element(*self.save_success_locator).text

